package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.AttendEmployeeMonth;
import cn.stylefeng.guns.sys.modular.system.model.params.AttendEmployeeMonthParam;
import cn.stylefeng.guns.sys.modular.system.service.AttendEmployeeMonthService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;


/**
 * 出勤_月度员工档案信息表控制器
 *
 * @author wjk
 * @Date 2021-11-15 11:05:38
 */
@Controller
@RequestMapping("/attendEmployeeMonth")
public class AttendEmployeeMonthController extends BaseController {

    private String PREFIX = "/modular/system/attendEmployeeMonth";

    @Autowired
    private AttendEmployeeMonthService attendEmployeeMonthService;

    /**
     * 跳转到主页面
     *
     * @author wjk
     * @Date 2021-11-15
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/attendEmployeeMonth.html";
    }

    /**
     * 新增页面
     *
     * @author wjk
     * @Date 2021-11-15
     */
//    @RequestMapping("/add")
//    public String add() {
//        return PREFIX + "/attendEmployeeMonth_add.html";
//    }

    /**
     * 编辑页面
     *
     * @author wjk
     * @Date 2021-11-15
     */
//    @RequestMapping("/edit")
//    public String edit() {
//        return PREFIX + "/attendEmployeeMonth_edit.html";
//    }

    /**
     * 新增接口
     *
     * @author wjk
     * @Date 2021-11-15
     */
//    @RequestMapping("/addItem")
//    @ResponseBody
//    public ResponseData addItem(AttendEmployeeMonthParam attendEmployeeMonthParam) {
//        this.attendEmployeeMonthService.add(attendEmployeeMonthParam);
//        return ResponseData.success();
//    }

    /**
     * 编辑接口
     *
     * @author wjk
     * @Date 2021-11-15
     */
//    @RequestMapping("/editItem")
//    @ResponseBody
//    public ResponseData editItem(AttendEmployeeMonthParam attendEmployeeMonthParam) {
//        this.attendEmployeeMonthService.update(attendEmployeeMonthParam);
//        return ResponseData.success();
//    }

    /**
     * 删除接口
     *
     * @author wjk
     * @Date 2021-11-15
     */
//    @RequestMapping("/delete")
//    @ResponseBody
//    public ResponseData delete(AttendEmployeeMonthParam attendEmployeeMonthParam) {
//        this.attendEmployeeMonthService.delete(attendEmployeeMonthParam);
//        return ResponseData.success();
//    }

    /**
     * 查看详情接口
     *
     * @author wjk
     * @Date 2021-11-15
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(AttendEmployeeMonthParam attendEmployeeMonthParam) {
        AttendEmployeeMonth detail = this.attendEmployeeMonthService.getById(attendEmployeeMonthParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author wjk
     * @Date 2021-11-15
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(AttendEmployeeMonthParam attendEmployeeMonthParam) {
        return this.attendEmployeeMonthService.findPageBySpec(attendEmployeeMonthParam);
    }

    /**
     * 同步单人的姓名
     *
     * @author wjk
     * @Date 2021-03-09
     */
    @RequestMapping("/synchronousNameById")
    @ResponseBody
    public ResponseData synchronousName(AttendEmployeeMonthParam attendEmployeeMonthParam) {
        Map<String,String> map = this.attendEmployeeMonthService.synchronousNameById(attendEmployeeMonthParam.getId());

        if (ToolUtil.isNotEmpty(map.get("falg"))&&map.get("falg").equals("true")) {
            return ResponseData.success(map);
        } else {
            return ResponseData.error(200, "失败", map);
        }

    }


}


